package mfuny.ggongal.admin.http;

import java.util.List;

import mfuny.ggongal.admin.Server;
import mfuny.ggongal.admin.json.JsonCreater;

import org.json.simple.JSONObject;

import com.ibatis.sqlmap.client.SqlMapClient;

public class HttpEvent {
	SqlMapClient sqlMapper;
	JsonCreater jc;
	
	public HttpEvent() throws Exception {
		sqlMapper = Server.getSqlMapper();
		jc = new JsonCreater(); 
	}
	
	//진행중인 이벤트 베너 리스트.
	@SuppressWarnings("unchecked")
	public JSONObject event_getEventToday() throws Exception {
		JSONObject json = null;
		List<Object> eventList = sqlMapper.queryForList("event_selectEventToday", null);
		
		if( eventList.size() > 0 ) {
			json = jc.getJsonByMapList( eventList, "eventList");
			json.put("responseCode", 1);
		} else {
			json = new JSONObject();
			json.put("responseCode", 0);
		}
		
		return json;
	}
	
	//특정번호의 이벤트 본문 내용 주기.
	public String event_getContentByNo(int ev_no) throws Exception {
		String content = (String) sqlMapper.queryForObject("event_eventContentByNo", ev_no);
		return content;
	}
}
